<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2020/9/1
 * Time: 17:13
 */
namespace app\shop\controller;
use think\Db;
class Freight extends Base {
    public function index(){
        if(request()->isPost()){
        $go_address = input('param.go_address');
        $to_address = input('param.to_address');
        $cc = input('param.cc');
        $latlog = addresstolatlag($go_address);//获取经纬度
        $latlog1 = addresstolatlag($to_address);//获取经纬度
        $log1 = round($latlog['log'],5);
        $lat1 = round($latlog['lat'],5);
        $log2 = round($latlog1['log'],5);
        $lat2 = round($latlog1['lat'],5);
        $origin = $log1.','.$lat1;
        $destination = $log2.','.$lat2;
        $result = aaa($origin,$destination);
        $res = '';
        if($cc=='4.2米及以下车型'){
            $res = 3*$result;
        }elseif ($cc=='6.8米车型'){
            $res = 6*$result;
        }elseif($cc=='9.6米车型'){
            $res = 7*$result;
        }elseif ($cc=='13米车型'){
            $res = 9*$result;
        }elseif ($cc=='17.5米车型'){
            $res = 11*$result;
        }
        if($res){
            return json(['status'=>200,'msg'=>round($res,2)]);
        }else{
            return json(['status'=>100,'msg'=>'失败']);
        }
    }

        $where['is_del'] = 1;
        $where['is_status'] = 1;
        $list = Db::table('up_car_cclb')->where($where)->where('cclb_id','in',array(1,2,3,4,5))->select();
        $where['is_del'] = 1;
        $where['is_status'] = 1;
        $list1 = Db::table('up_car_cx')->where($where)->select();
        $this->assign('list',$list);
        $this->assign('list1',$list1);
        return $this->fetch();
    }

}